import { service as axios } from '@vimi/utils-api'
// import { queryTrouble } from '@vimi/utils-api'
const keyAndValue = params => {
  let str = ''
  Object.keys(params).forEach((key, index) => {
    if (index === 0) {
      str += `?${key}=${params[key]}`
    } else {
      str += `&${key}=${params[key]}`
    }
  })
  return str
}

// 通用查询方法
export const getData = (tableName, params) => axios.get(`/cfca/${tableName}${keyAndValue(params)}`)

// 通用添加方法
export const addData = (tableName, data) => axios.post(`/cfca/${tableName}`, data)

// 通用修改方法
export const updateData = (tableName, data) => axios.put(`/cfca/${tableName}${keyAndValue(data)}`)
